package com.servicesDirectory.action.organisation.team;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.servicesDirectory.bo.organisation.directorate.DirectorateBOImpl;
import com.servicesDirectory.bo.organisation.team.TeamBOImpl;
import com.servicesDirectory.common.vo.BaseGovernmentVO;
import com.servicesDirectory.common.vo.organisation.DirectorateVO;
import com.servicesDirectory.common.vo.organisation.TeamVO;
import com.servicesDirectory.dao.organisation.team.TeamDAOImpl;

public class TeamAction extends ActionSupport {
	
	
	public List<TeamVO> teamList;
	protected TeamVO team = new TeamVO();
	public int teamID;
	String filter = "";
	boolean checkInclude;
	TeamBOImpl bo;
	protected String error ;	
	protected String teamName;
	protected String shortDesc;
	protected String addr1;
	protected String addr2;
	protected String addr3;
	protected String postCode;
	protected String townName;
	protected String countyName;
	protected String countryName;
	protected int contactID =1;
	protected int typeOfBusinessID =1;
	protected String fullDesc;
	protected String phoneNumber;
	protected String fax;
	protected String email;
	protected String webAddr;
	protected int departmentID=3;
	protected int isActive;
	protected String contactName;
	


   

	@Override
    public void validate() {
    }
    
public String listTeam() {		
		TeamDAOImpl bo = new TeamDAOImpl();	
		this.teamList = bo.listTeam(departmentID, filter, checkInclude);
		return SUCCESS;

	}

	
	private static final long serialVersionUID = 1L;

	@Override
	public String execute() {
		return SUCCESS;
	}

	public String addTeam() {
		TeamDAOImpl dao = new TeamDAOImpl();
		team = new TeamVO(0, getTeamName(), getShortDesc(), getContactID(), 0, getAddr1(), getAddr2(), getAddr3(),
				getPostCode(), getTownName(), getCountyName(), getCountryName(), 1 , getFullDesc(), 
				getPhoneNumber(), getFax(), getEmail(), getWebAddr(), getDepartmentID(), getIsActive());
		if(dao.addTeam(team)){
			return SUCCESS;
		}
		else{
			return "error";
		}
	}
	
	public boolean validateAdd(){
		boolean checkAdd = false;
		if(teamName.equals("") || teamName == null){
			checkAdd = false;
			setError("Team can't be empty !</br>");
		}
		
		else{
			checkAdd = true;
		}
		if(checkAdd){
			team.setTeamName(teamName);
			team.setShortDesc(shortDesc);
			team.setAddr1(addr1);
			team.setAddr2(addr2);
			team.setAddr3(addr3);
			team.setContactID(contactID);
			team.setCountyName(countyName);
			team.setCountryName(countryName);
			team.setPostcode(postCode);
			team.setPhoneNumber(phoneNumber);
			team.setTownName(townName);
			team.setFullDesc(fullDesc);
			team.setEmail(email);
			team.setFax(fax);
			team.setWebAddr(webAddr);
			return true;
		}
		else{
			return false;
		}
		
	}


	public Object getModel() {
		return team;
	}

	
	public String getError() {
		return error;
	}

	public void setError(String error) {
		this.error = error;
	}

	public String getTeamName() {
		return teamName;
	}

	public void setTeamName(String teamName) {
		this.teamName = teamName;
	}

	public String getShortDesc() {
		return shortDesc;
	}

	public void setShortDesc(String shortDesc) {
		this.shortDesc = shortDesc;
	}

	public String getAddr1() {
		return addr1;
	}

	public void setAddr1(String addr1) {
		this.addr1 = addr1;
	}

	public String getAddr2() {
		return addr2;
	}

	public void setAddr2(String addr2) {
		this.addr2 = addr2;
	}

	public String getAddr3() {
		return addr3;
	}

	public void setAddr3(String addr3) {
		this.addr3 = addr3;
	}

	public String getPostCode() {
		return postCode;
	}

	public void setPostCode(String postCode) {
		this.postCode = postCode;
	}

	public String getTownName() {
		return townName;
	}

	public void setTownName(String townName) {
		this.townName = townName;
	}

	public String getCountyName() {
		return countyName;
	}

	public void setCountyName(String countyName) {
		this.countyName = countyName;
	}

	public String getCountryName() {
		return countryName;
	}

	public void setCountryName(String countryName) {
		this.countryName = countryName;
	}

	public int getContactID() {
		return contactID;
	}

	public void setContactID(int contactID) {
		this.contactID = contactID;
	}

	public String getFullDesc() {
		return fullDesc;
	}

	public void setFullDesc(String fullDesc) {
		this.fullDesc = fullDesc;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getFax() {
		return fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getWebAddr() {
		return webAddr;
	}

	public void setWebAddr(String webAddr) {
		this.webAddr = webAddr;
	}
	
	public TeamVO getTeam() {
		return team;
	}

	public void setTeam(TeamVO team) {
		this.team = team;
	}


	

	public int getTypeOfBusinessID() {
		return typeOfBusinessID;
	}

	public void setTypeOfBusinessID(int typeOfBusinessID) {
		this.typeOfBusinessID = typeOfBusinessID;
	}

	public int getDepartmentID() {
		return departmentID;
	}

	public void setDepartmentID(int departmentID) {
		this.departmentID = departmentID;
	}

	

	public String getContactName() {
		return contactName;
	}

	public void setContactName(String contactName) {
		this.contactName = contactName;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public List<TeamVO> getTeamList() {
		return teamList;
	}

	public void setTeamList(List<TeamVO> teamList) {
		this.teamList = teamList;
	}

	public int getTeamID() {
		return teamID;
	}

	public void setTeamID(int teamID) {
		this.teamID = teamID;
	}

	public String getFilter() {
		return filter;
	}

	public void setFilter(String filter) {
		this.filter = filter;
	}

	public boolean isCheckInclude() {
		return checkInclude;
	}

	public void setCheckInclude(boolean checkInclude) {
		this.checkInclude = checkInclude;
	}

	public TeamBOImpl getBo() {
		return bo;
	}

	public void setBo(TeamBOImpl bo) {
		this.bo = bo;
	}

	public int getIsActive() {
		return isActive;
	}

	public void setIsActive(int isActive) {
		this.isActive = isActive;
	}
	
	
	
}